<template>
  <div>
    <div style="height:440px;overflow-y:scroll;">
      <el-input v-model="xml" :rows="20" type="textarea"></el-input>
    </div>
  </div>
</template>
<script>
import { redeploy as redeployProcess, getXml } from '@/api/wf/wf.process.service.js'

export default {
  name: 'WfProcessAdd',
  props: {
    id: {
      type: [String, Number],
      default: undefined
    }
  },
  data() {
    return {
      xml: ''
    }
  },
  mounted() {
    getXml({
      id: this.id
    }).then(res => {
      if (res.code === 0) {
        this.xml = res.data
      }
    })
  },
  methods: {
    submit() {
      // return this.$refs.form.submit()
      return new Promise((resolve, reject) => {
        redeployProcess(this.id, this.xml).then(res => {
          if (res.code === 0) {
            this.$message({
              message: res.msg || '操作成功',
              type: 'success'
            })
          }
          resolve(res)
        }).catch(e => {
          reject(e)
        })
      })
    },
    resetFields() {
      // this.$refs.form.resetFields()
      this.xml = ''
    }
  }
}
</script>
